package com.zb.jsp.dao.active;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;


import com.zb.jsp.common.HibernateSessionFactory;
import com.zb.jsp.vo.advert.AdvertVo;


public class AdvertInfoDao {
	

	Session session = null;
	Transaction transaction = null;
	
	/**	
	 * 查询广告名和广告id
	 * @return advertVoList 传回广告id和广告名
	 */
	public List<AdvertVo> findAdvertInfoList(String hql) {
		List<AdvertVo> advertVoList = null;
		
		try {
			// 1.创建 Session链接
			session = HibernateSessionFactory.getSession();						
			// 2.获得一个查询的query
			Query hqlQuery = session.createQuery(hql);
			// 3.执行查询动作
			advertVoList = hqlQuery.list();

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			// 4.关闭session
			HibernateSessionFactory.closeSession();
		}
		
		return advertVoList;	
	}
}
